<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>商之联运营商后台管理系统</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="table">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="{:C('SUPPLIER_ADMIN_IMAGE')}favicon.png"> <link rel="apple-touch-icon-precomposed" href="{:C('SUPPLIER_ADMIN_IMAGE')}app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="{:C('SUPPLIER_ADMIN_CSS')}amazeui.min.css"/>
  <link rel="stylesheet" href="{:C('ADMIN_CSS')}admin.css">
</head>
<body>
 <style type="text/css">
/*  .tabbox td{text-align: center;}
.am-btn-toolbar .am-btn-group, .am-btn-toolbar .am-input-group{
 float: none;
}
*/</style> 
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->
<!-- header start-->

<include file="Public:header"/>


<!-- header end-->

<div class="am-cf admin-main">
 <!-- sidebar start -->
   <include file="Public:menu"/>
  <!-- sidebar end -->
  
  <!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">活动管理</strong> / <small>活动列表</small></div>
    </div>
    
      <!-- 搜索条件start -->
 



    <div class="am-g">
      <div class="am-u-sm-12">
        <form class="am-form">
          <table class="am-table am-table-striped am-table-hover table-main devicetable" data-am-tabs="{noSwipe: 1}">
            <thead>
              <tr>
                <th class="table-id">序号</th>
                <th class="table-title">活动标题</th>
                <th class="table-title">活动父标题</th>
               
                <th class="table-title">开始时间</th>
                <th class="table-title">结束时间</th>
                <th class="table-title">分配规则</th>
                <th class="table-title">上线</th>
                <th class="table-set">操作</th>
              </tr>
          </thead>
          <tbody>
           <volist name="activity" id="act">
           <tr class="tabbox">
                      
         
          <td>{$act.id}</td>
          <td>{$act.parenttheme}</td>
          <td></td>
           <td></td>
            <td></td>
            <td>{$act['type']}</td>
            <td> <if condition="$act['state'] eq 0">

               <span class='am-icon-arrow-down' value="{$act['id']}" ></span>
                <else/>
                <span class='am-icon-arrow-up'  value="{$act['id']}"></span></if>
               </td>
                <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary" >
                   <span class="am-icon-pencil-square-o">  <a  onclick="ajaxdel({$act['id']})"> 删除</a></span>
                 </button>
                   <button class="am-btn am-btn-default am-btn-xs am-text-secondary"  type="button" >
                   <span class="am-icon-pencil-square-o">  <a href="{:U('Activity/parentedit',array('id'=>$act['id']))}" >编辑 </a></span>
                 </button>
                  <button class="am-btn am-btn-default am-btn-xs am-text-secondary child" type="button" value="{$act['id']}"  >
                   <span class="am-icon-pencil-square-o">  <a >添加子活动</a></span>
                 </button>
                  <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                   <span class="am-icon-pencil-square-o">  <a href="{:U('Activity/device',array('id'=>$act['id'],'type'=>$act['type']))}">设置活动设备 </a></span>
                 </button>
                 
                  </div>
                </div>
              </td>
               <volist name="act['child']" id="ac">
              <tr class="tabbox">
              <td>{$ac['id']}</td>
            <td>{$ac['childtheme']}</td>
            <td>{$ac['parenttheme']}</td>
             <td><?php echo date("Y-m-d H:i:s",$ac['opentime'])?></td>
              <td><?php echo date("Y-m-d H:i:s",$ac['endtime'])?></td>
            <td></td>
            <td></td>
            
            <td>
               <div class="am-btn-toolbar">
               <div class="am-btn-group am-btn-group-xs">
                 <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                <span class="am-icon-pencil-square-o">  <a onclick="del({$ac['id']})"> 删除</a></span>
              </button>
               <button class="am-btn am-btn-default am-btn-xs am-text-secondary">
                 <span class="am-icon-pencil-square-o">  <a href="{:U('Activity/childedit',array('id'=>$ac['id']))}">编辑 </a></span>
               </button>
               
                  </button> 
               </div>
             </div> 
            </td>
            </tr>
            </volist>
              
                       
           </tr>
           </volist>
          
          </tbody>
        </table>
         
      <div class="am-fr">
    <ul class="am-pagination">
      <li><a href="{:U('Activity/index',array('page'=>$pagearr['prevpage']))}">«</a></li>
       <?php $k=0; ?>
      <for start="$pagearr['page']" end="$pagearr['pagetotal']+1"  name='i' step="1">
         <if condition="$k lt 6">
           <li <if condition="$i eq $pagearr['page']"> class="am-active" </if>  > <a href="{:U('Yunying/index',array('page'=>$i))}">{$i}</a></li>
         </if>
       <?php $k+=1;  ?>
      </for>
      
      <li><a href="{:U('Activity/index',array('page'=>$pagearr['nextpage']))}">»</a></li>
    </ul>
  </div>
</div>


        </form>
      </div>

    </div>
  </div>
  <!-- content end -->

 </div> 
 <!--子主题追加start-->
 <div class="am-popup" id="my-popup">
  <div class="am-popup-inner">
    <div class="am-popup-hd">
      <h4 class="am-popup-title">追加子活动</h4>
      <span data-am-modal-close class="am-close">&times;</span>
    </div>
   <div class="am-popup-bd">
     <form action="{:U('Activity/childadd')}" method="post" enctype="multipart/form-data"> 
     <br/>
             <div class="am-g am-margin-top">
                     <div class="am-u-sm-4 am-u-md-2 am-text-right">
                      活动子标题:
                     </div>
                     <div class="am-u-sm-8 am-u-md-10 theme">
                      <input type="text" name="childtheme" required />

                     </div>
                   </div> 
                   
   <div class="am-g am-margin-top">
      <div class="am-u-sm-4 am-u-md-2 am-text-right">
        子主题图片:
      </div>
      <div class="am-u-sm-8 am-u-md-10">
        <input type="file" class="am-input-sm" name="childimg" required="true" />
         <p class="am-form-help">请选择要上传的文件...(像素要求1280*670)<span class="require-field">*</span></p>
      </div>
    </div>
  
  
       <div class="am-g am-margin-top">
          <div class="am-u-sm-4 am-u-md-2 am-text-right">
            活动开始时间:
          </div>
          <div class="am-u-sm-8 am-u-md-10">
            <input class="laydate-icon" id="start" style="width:200px; margin-right:10px;" name="opentime" />
          </div>
  
        </div>
       
         <div class="am-g am-margin-top">
          <div class="am-u-sm-4 am-u-md-2 am-text-right">
            活动结束时间:
          </div>
          <div class="am-u-sm-8 am-u-md-10">
            <input class="laydate-icon" id="end" style="width:200px;" name="endtime"/>
          </div>
        </div>
        
       
        <div class="am-margin">
  <button type="submit" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
  <button type="reset" class="am-btn am-btn-primary am-btn-xs">放弃保存</button>
    </div>
    </form>

   </div>
  </div>
</div>
 <!--子主题追加end-->

<script src="{:C('ADMIN_JS')}jquery.min.js"></script>
<include file="Public:footer"/>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/rem.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}polyfill/respond.min.js"></script>
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.legacy.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="{:C('SUPPLIER_ADMIN_JS')}amazeui.min.js"></script>
<!--<![endif]-->
<script src="{:C('SUPPLIER_ADMIN_JS')}app.js"></script>
<script src="{:C('ADMIN_JS')}laydate/laydate.js"></script>

<script type="text/javascript">
  ///删除父活动
 function ajaxdel(id){
    var res=confirm("确定要删除该活动吗");
    if(!res){
      return false;
    }else{
       var aid=id;
    $.ajax({
      type:'GET',
       data:{"id":aid},
       url: "{:U('Activity/parentdel')}",
      dataType:"text",
      success:function(data){
      if(data==1){
        alert("删除成功");
       }if(data==2){
        alert("操作失误");
       }

      }
    })

  }///else结束
  }
</script>
<script type="text/javascript">
  ////删除子活动
  function del(id){
     var res=confirm("确定要删除该活动吗");
    if(!res){
      return false;
    }
       var aid=id;
    $.ajax({
      type:'POST',
       data:{"id":aid},
       url: "{:U('Activity/childdel')}",
      dataType:"text",
      success:function(data){
        
      if(data==1){
        alert("删除成功");
       
       }if(data==2){
        alert("操作失误");
       }

      }
    })

  


  }
</script>
<script type="text/javascript">
  ////添加子活动
  $(".child").click(function(){
    var $this=$(this);
    var pid=$this.attr('value');
    var $str="<input type='hidden' name='pid' value="+pid+">";
    $(".theme").append($str);
    $('#my-popup').modal();
 

  })

</script>

<script type="text/javascript">
  ///活动上线

    $(".am-icon-arrow-down").click(function(){
     var $this=$(this);
        var id=$this.attr('value');
         jQuery.get('{:U("Activity/online")}',
  {id:id,},
  function(data){
  if(data.status===200){
    alert(data.info);
     $this.attr('class','am-icon-arrow-up');
  }
 },'json');

    })
    
    ////或送下线
       $(".am-icon-arrow-up").click(function(){
     var $this=$(this);
        var id=$this.attr('value');
         jQuery.get('{:U("Activity/downline")}',
  {id:id,},
  function(data){
  if(data.status===200){
    alert(data.info);
    $this.attr('class','am-icon-arrow-down');


  }
 },'json');

    })

</script>
<script type="text/javascript">
  
  var start = {
    elem: '#start',
    format: 'YYYY/MM/DD hh:mm:ss',
    min: laydate.now(), //设定最小日期为当前日期
    max: '2099-06-16 23:59:59', //最大日期
    istime: true,
    istoday: false,
    choose: function(datas){
         end.min = datas; //开始日选好后，重置结束日的最小日期
         end.start = datas //将结束日的初始值设定为开始日
    }
};
var end = {
    elem: '#end',
    format: 'YYYY/MM/DD hh:mm:ss',
    min: laydate.now(),
    max: '2099-06-16 23:59:59',
    istime: true,
    istoday: false,
    choose: function(datas){
        start.max = datas; //结束日选好后，重置开始日的最大日期
    }
};
laydate(start);
laydate(end);
</script>






</body>